package application;

import java.awt.Color;
import java.io.FileNotFoundException;
import java.io.IOException;

import files.TetrisData;
import files.XMLTools;

public class XMLTester {

	/**
	 * @param args
	 */
	/*public static void main(String[] args) {
		TetrisData ct = new TetrisData();
		ct.setPlayer("Jaja");
		ct.setScore(3000);
		ct.setLevel(4);
 		ct.getColorSet().put("T", Color.ORANGE);
		
		printCT(ct, "Objet de base à sérialiser");
				
		String fileName = "config.xml";
		
		try {
			System.out.println("Writing file...");
			XMLTools.encodeToFile(ct, fileName);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		ct = new TetrisData();
		ct.setPlayer("Jojo");
		ct.setScore(200);
		ct.setLevel(2);
		
		printCT(ct, "Objet modifié");
		
		try {
			ct = (TetrisData) XMLTools.decodeFromFile(fileName);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		printCT(ct, "Objet désérialisé");
		
	}

	private static void printCT(TetrisData ct, String title){
		System.out.println(title);
		System.out.println(ct);
		System.out.println("Joueur : " + ct.getPlayer());
		System.out.println("Niveau : " + ct.getLevel());
		System.out.println("Score : " + ct.getScore());
		System.out.println("Couleurs : " + ct.getColorSet());
	}
	*/
}
